home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / mayaClockDemo.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  3.2 KB  |  138 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. proc int server(string $dName, string $sName)
  18. {
  19.     //defineDataServer -d $dName -s $sName;
  20.     return initDataServer($dName,$sName,"localhost", "", "",2);
  21. }
  22.  
  23. proc attach1D(    string $device, string $channel, float $scale,
  24.                 string $target, string $attribute)
  25. {
  26.     string $axisName;
  27.     $axisName = $channel;
  28.     string $atrName = $target+"."+$attribute;
  29.  
  30.     attachDeviceAttr -d $device -ax $axisName $atrName;
  31.     setAttrMapping -a -d $device -ax $axisName -at $attribute -s $scale;
  32. }
  33.  
  34. proc string makeCylinder()
  35. {
  36.     string $sarr[] = `cylinder -ax 0 1 0`;
  37.     return $sarr[0];
  38. }
  39.  
  40. proc attachHands(string $device, string $hands[] )
  41. {
  42.     attach1D($device, "seconds", 1.0, $hands[0], "rz");
  43.     attach1D($device, "minutes", 1.0, $hands[1], "rz");
  44.     attach1D($device, "hours",   1.0, $hands[2], "rz");
  45. }
  46.  
  47. proc makeHands( string $dName, string $hands[] )
  48. {
  49.     //    Second hand
  50.     //
  51.     $hands[0] = makeCylinder();
  52.     scale -a .1 6 .1 $hands[0];
  53.     $rp = $hands[0]+".rotatePivot";
  54.     select -r $rp;
  55.     move -r 0 -6 0;
  56.     select -r $hands[0];
  57.     move -r 0 6 0;
  58.     select;
  59.  
  60.     //    Minute hand
  61.     //
  62.     $hands[1] = makeCylinder();
  63.     scale -a .25 6 .25 $hands[1];
  64.     $rp = $hands[1]+".rotatePivot";
  65.     select -r $rp;
  66.     move -r 0 -6 0;
  67.     select -r $hands[1];
  68.     move -r 0 6 0;
  69.     select;
  70.     
  71.     //    Hour hand
  72.     //
  73.     $hands[2] = makeCylinder();
  74.     scale -a .5 4 .5 $hands[2];
  75.     $rp = $hands[2]+".rotatePivot";
  76.     select -r $rp;
  77.     move -r 0 -4 0;
  78.     select -r $hands[2];
  79.     move -r 0 4 0;
  80.     select;
  81.     
  82.     attachHands($dName, $hands);
  83. }
  84.  
  85. proc makeFace()
  86. {
  87.     select;
  88.     textCurves -s 8 -n "three" 3;
  89.     select "three";
  90.     move -a 9.8615 -2.62462 0;
  91.  
  92.     select;
  93.     textCurves -s 8 -n "six" 6;
  94.     select "six";
  95.     move -a -2 -14.348 0;
  96.  
  97.     select;
  98.     textCurves -s 8 -n "nine" 9;
  99.     select "nine";
  100.     move -a -13.6563 -2.5 0;
  101.  
  102.     select;
  103.     textCurves -s 8 -n "twelve" 12;
  104.     select "twelve";
  105.     move -a -4.30736 9 0;
  106.  
  107.     select;
  108.     sphere;
  109.  
  110.     select -tgl;
  111. }
  112.  
  113. global proc string mayaClockDemo()
  114. {
  115.     if (!`licenseCheck -m "edit" -typ "complete"`) {
  116.         error("You are not licensed to use the \"mayaClockDemo\" MEL proc.");
  117.     }
  118.  
  119.     string $dName="clock";
  120.     string $sName="mayaClockServer";
  121.  
  122.     if ( 0 != server($dName, $sName) ) {
  123.         error("Couldn't launch " + $sName );
  124.         return "";
  125.     }
  126.  
  127.     string $hands[3];
  128.  
  129.     makeHands($dName, $hands);
  130.     rename $hands[0] second_hand;
  131.     rename $hands[1] minute_hand;
  132.     rename $hands[2] hour_hand;
  133.  
  134.     //makeFace();
  135.     return $sName;
  136. }
  137.  
  138.